import axios from 'axios'

// create axios实例
const request = axios.create({
  // timeout: 2000
})

const tokenMessage = JSON.parse(window.localStorage.getItem('user'))

export const getUserInfo = () => {
  return axios.create({
    method: 'get',
    url: 'http://localhost:3000/userInfo',
    headers: {
      Authorization: tokenMessage.token
    }
  })
}

// 退出按钮
export const testUser = () => {
  if (window.localStorage.getItem('user') == null) {
    this.$router.push({
      name: 'login'
    })
  }
}

export default request
